package com.ssm.subject.domain.job;

import com.ssm.subject.domain.service.SubjectLikedDomainService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Log4j2
public class SyncLikedJob {
    @Resource
    private SubjectLikedDomainService subjectLikedDomainService;

    /**
     * 数据库同步redis点赞数据
     * @throws Exception
     */
    @XxlJob("syncLikedJobHandler")
    public void syncLikedJobHandler() throws Exception {
        XxlJobHelper.log("syncLikedJobHandler.start"); //xxljob的日志方法会在任务调度中心显示
        try {
            subjectLikedDomainService.syncLiked();
        } catch (Exception e) {
            XxlJobHelper.log("syncLikedJobHandler.error" + e.getMessage());
        }
    }

}
